﻿using Joy.Erp.BasicArchives;
using Joy.Erp.Ufida.Core;
using Joy.Erp.Ufida.Production;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;

namespace Joy.Erp.Ufida.Receipt
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("ReceivementSync")]
    [Route("api/basic-archives/receivement-sync")]
    public class ReceivementSyncController : UfidaController, IReceivementSyncAppService
    {
        protected IReceivementSyncAppService ReceivementSyncAppService => LazyServiceProvider.LazyGetRequiredService<IReceivementSyncAppService>();

        [HttpPost]
        [Route("analyze")]
        public Task<AnalysisDto> AnalyzeAsync(DateTime start, DateTime end)
        {
            return ReceivementSyncAppService.Analyze‌Async(start, end);
        }

        [HttpGet]
        public Task<List<long>> GetUnasyncIds(DateTime start, DateTime end)
        {
            return ReceivementSyncAppService.GetUnasyncIds(start, end);
        }

        [HttpGet]
        [Route("synced-ids")]
        public Task<List<long>> GetSyncedIds(DateTime start, DateTime end)
        {
            return ReceivementSyncAppService.GetSyncedIds(start, end);
        }

        [HttpPost]
        [Route("create-by-ids")]
        [ServiceFilter(typeof(CreateByIdExceptionFilter))]
        public Task<int> CreateByIdsAsync(long[] ids, DateTime start, DateTime end)
        {
            return ReceivementSyncAppService.CreateByIds‌Async(ids, start, end);
        }

        [HttpPost]
        [Route("update-by-ids")]
        [ServiceFilter(typeof(CreateByIdExceptionFilter))]
        public Task<int> UpdateByIdsAsync(long[] ids, DateTime start, DateTime end)
        {
            return ReceivementSyncAppService.UpdateByIds‌Async(ids, start, end);
        }
    }
}
